package com.cap.bts.crmdp.dealer.meal.dao.impl;

import java.util.List;

import javax.inject.Inject;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Repository;

import com.cap.bts.crmdp.dealer.meal.dao.IPackageDealerSelectedDao;
import com.cap.bts.crmdp.dealer.meal.domain.PackageDealerSelected;
import com.cap.bts.framework.common.dao.impl.BaseDaoImpl;
import com.cap.bts.framework.common.exception.AppException;


@Repository("iPackageDealerSelectedDao")
public class PackageDealerSelectedDaoImpl extends BaseDaoImpl<PackageDealerSelected, Long> implements IPackageDealerSelectedDao {

    @Inject
    public PackageDealerSelectedDaoImpl(@Value("com.cap.bts.crmdp.dealer.meal.domain.PackageDealerSelected") Class<PackageDealerSelected> clazz) {
        super(clazz);

    }

	@Override
	public List<PackageDealerSelected> getPackageSelected(String packageDefId,String dealerId) throws AppException {
		String sql = "select * from tm_raw_package_dealer_select where package_def_id = '" + packageDefId +
				"' and dealer_id = '" + dealerId + "'";
		return this.getListByNativeQuery(sql);
	}

	@Override
	public void removePackageSelected(String dealerId) throws AppException {
		String sql = "delete from tm_raw_package_dealer_select where  dealer_id = '" + dealerId + "'";
		this.getEntityManager().createNativeQuery(sql).executeUpdate();
	}

}
